#include "textfield.h"
#include <QtPlugin>
#include <QLabel>
#include <QPlainTextEdit>

TextField::TextField()
{
}

QWidget *TextField::createDelegate(const QVariantMap &properties)
{
    Q_UNUSED(properties)
    QPlainTextEdit *edit = new QPlainTextEdit();
    return edit;
}

void TextField::setEditable(QWidget *delegate, bool editable)
{
    QPlainTextEdit *edit = (QPlainTextEdit *)delegate;
    edit->setReadOnly(!editable);
}

QVariant TextField::data(QWidget *delegate) const
{
    QPlainTextEdit *edit = (QPlainTextEdit *)delegate;
    return edit->toPlainText();
}

void TextField::setData(QWidget *delegate, const QVariant &data)
{
    QPlainTextEdit *edit = (QPlainTextEdit *)delegate;
    edit->setPlainText(data.toString());
}

void TextField::clear(QWidget *delegate)
{
    QPlainTextEdit *edit = (QPlainTextEdit *)delegate;
    edit->clear();
}

Q_EXPORT_PLUGIN2(text-field, TextField)
